package com.activeMq.persistence;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

public class Producer {
    public static void main(String[] args) throws JMSException {
        ConnectionFactory factory=new ActiveMQConnectionFactory("tcp://127.0.0.1:61616");
        Connection connection=factory.createConnection();
        connection.start();
        Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
        Queue queue=session.createQueue("tx_queue2");
        MessageProducer producer=session.createProducer(queue);
         //默认持久化 ，设置不持久化
        //producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
        for (int i = 0; i <10 ; i++) {
            TextMessage message=session.createTextMessage("你好吗"+i);
            producer.send(message);
        }

        producer.close();
        session.close();
        connection.close();
    }
}
